package com.chj.chuji.tijie06;

public class DfsTree {
	public static int dfs(int x, int y) {
		if (x == y) {
			return x;
		}
		return x > y ? dfs(x / 2, y) : dfs(x, y / 2);

	}

	public static void main(String[] args) {
//		Scanner sc = new Scanner(System.in);
//		while (sc.hasNext()) {
//			int x = sc.nextInt();
//			int y = sc.nextInt();

		int x = 10;
		int y = 4;

//		 非递归 
		while (x != y) {
			if (y > x) {
				y = y / 2;
			} else {
				x = x / 2;
			}
		}
		System.out.println(x);

		System.out.println(dfs(x, y));
//		}
	}
}
